<?php
 /*************************************************\
    TV-Program
    Version: 2.5
    Author: Dmitri M. Furmanoff
    E-mail: furik@mail.ru
    \*************************************************/

    /*************************************************\
    Компонент: Телепрограммы
    Версия: 2.5
    Автор: Дмитрий Фурманов
    E-mail: furik@mail.ru
    \*************************************************/

defined ('_VALID_MOS') or die('Доступ к файлу запрещен.');

require_once($mosConfig_absolute_path."/administrator/components/com_tv/config.tv.php");

$isrem=0;

$today=getdate($mostime);
$dayofweek = $today['wday']; 
$dayofweek=$dayofweek?$dayofweek:7;
$i=0;
echo "<form name=tv_reminder method=post action=".sefRelToAbs("index.php?option=com_tv")."'>";
if(count($Channel)){
$wherec=" in (";
foreach($Channel as $k=>$v) {
$ch[$k]=intval($v);
}
$wh=implode(",",$ch);
$wherec=$wherec.$wh.")";
}
else
  $wherec=" is null";
if(count($day)){
for($j=0;$j<count($day);$j++) {
$vv=intval($day[$j]);
$dat=mktime(0,0,0,$today['mon'],$today['mday']-$dayofweek+$vv,$today['year']);

$qr="SELECT tc.channelname, tc.channellogo, tp.pid, tp.date, tp.channel, tp.name, tp.hour, tp.minute
FROM #__tvchannels tc
INNER JOIN #__tvprogramms tp ON tc.cid = tp.channel
WHERE tp.date='".date("Y-m-d",$dat)."' AND tc.cid ".$wherec." AND tc.published=1
ORDER BY tc.ordering, tp.order";

$database->setQuery($qr);
$programms=$database->loadObjectList();
$nc=0;
$i=0;
echo "<b><center>".$a_weekl[$vv-1].", ".date("d.m.Y",$dat)."</center></b>";
echo "<table width=100% border=0 cellspacing=0 cellpadding=0>";
echo "<tr><td>";
echo "<table width=100% border=0 cellspacing=1>";
foreach($programms as $programm)
{
if($programm->channel != $nc)
     {
     echo "<tr class=sectiontableheader><td colspan=";
     if($my->id)
        echo "3";
     else
        echo "2";   
     echo ">";
     if(strlen($programm->channellogo))
       echo "<img src='$mosConfig_live_site/$pathlogo/$programm->channellogo' border=0 width=40 height=32 align=\"absmiddle\" vspace=2>";
     else
       echo "<img src='$mosConfig_live_site/images/blank.png' border=0 width=40 height=32 align=\"absmiddle\" vspace=2>";
     echo "$programm->channelname</td></tr>";
     }

echo "<tr class=sectiontableentry".($i % 2 + 1).">";
if(strlen($filter) && eregi($filter,$programm->name))
  {
  echo "<td width=\"30\"><b>".$programm->hour.":".$programm->minute."</b></td>";
  echo "<td><b>".$programm->name."</b></td>";
  }
else
 {
  echo "<td width=\"30\">".$programm->hour.":".$programm->minute."</td>";
  echo "<td>".$programm->name."</td>";
  }
if($my->id)
{
echo "<td>";
if(strtotime($programm->date)>$mostime)
 {
   echo "<input type=checkbox name=Reminder[] value=".$programm->pid.">";
   $isrem=1;
 }
echo "&nbsp;</td>";
}
echo "</tr>";

if($showanons && $ShowComments)
 {
  $qr="SELECT * FROM #__tvanons WHERE date='".date("Y-m-d",$dat)."' AND channel = ".$programm->channel." AND hour=$programm->hour AND minute=$programm->minute AND about<>''";

  $database->setQuery($qr);
  $anons=$database->loadObjectList();
  if(count($anons)){
    echo "<tr class=sectiontableentry".($i % 2 +1)."><td width=30>&nbsp;</td>";
    echo "<td>".$anons[0]->about."</td>";
 if($my->id)
  {
   echo "<td></td>";
  }
 echo "</tr>";
 }     
 }
$nc=$programm->channel;
$i++;

}
echo "</table></td></tr></table>";
}
echo "<input type=hidden name=task value='reminder'>";
if($isrem)
 echo "<div align=right><input type=submit class='button' value="._TV_BUTTONREMINDER."></div>";
echo "</form>";


// Draw the Back button.
mosHTML::BackButton( $params );
}
else
 echo _TV_NODAY;
?>
